package com.szh.mysobproject.viewmodel

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.szh.mysobproject.model.UserShare
import com.szh.mysobproject.paging.source.UserSharePagingSource
import kotlinx.coroutines.flow.Flow

class ShareViewModel : ViewModel() {

    fun loadUserShareList(userIs: String): Flow<PagingData<UserShare.Content>> {
        return Pager(config = PagingConfig(30),
            pagingSourceFactory = { UserSharePagingSource(userIs) })
            .flow.cachedIn(viewModelScope)
    }

}